<?php get_instance()->view('common/header');?>
<style type="text/css">
    <!--
    .text-val {
        padding-top: 3px;
        padding-left: 0;
    }

    .text-label {
        color: grey;
        text-align: right;
    }

    .btn-group, .btn-group-vertical {
        display: inline-block;
        position: absolute;
        vertical-align: middle;
    }

    .sale-summary li:first-child {
        border-top: medium none;
    }

    .sale-summary li {
        border-top: 1px solid #eee;
        overflow: hidden;
        padding: 10px 0;
    }

    .sale-summary li .sale-info {
        color: #646464;
        float: left;
        font-size: 14px;
        text-transform: uppercase;
    }

    .sale-summary li .sale-num {
        color: #169ef4;
        float: right;
        font-size: 20px;
        font-weight: 300;
    }

    .description-box img {
        width: 100%;
    }
    .remove:hover{
    	color: red;
    	cursor: pointer;
    }
    -->
</style>
<style type="text/css">
    div .radio-inline:nth-child(2), div .checkbox-inline:nth-child(2) {
        margin-left: 10px;
    }
    div.form-body>.tab-pane{display: none}
    div.form-body>.tab-pane.active{display: block}

    .table-scrollable > .table > thead > tr > th, .table-scrollable > .table > tbody > tr > th, .table-scrollable > .table > tfoot > tr > th, .table-scrollable > .table > thead > tr > td, .table-scrollable > .table > tbody > tr > td, .table-scrollable > .table > tfoot > tr > td{
        word-break:break-all;
    }
</style>
<div class="page-container home">
    <?php get_instance()->view('common/sidebar');?>
    <div class="page-content-wrapper">
        <div class="page-content">
            <div class="row">
                <div class="col-md-12">
                    <!-- BEGIN PAGE TITLE & BREADCRUMB-->
                    <h3 class="page-title"><?php echo $title?></h3>
                    <ul class="page-breadcrumb breadcrumb">
                        <li class="btn-group"> <a class="btn default ml_5 return" href="<?php echo $backUrl;?>"><i class="fa fa-chevron-left"></i> 返回</a> </li>
                        <li> <i class="fa fa-home"></i><a href="<?php echo $backUrl;?>"> 商品列表  <i class="fa fa-angle-right"></i> </a></li>
                        <li><a href="javascript:void(0);">详情</a></li>
                    </ul>
                    <!-- END PAGE TITLE & BREADCRUMB-->
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="row">
                        <div class="col-md-12 profile-info">
                            <div class="row">
                                <div class="col-md-12">
                                    <div style="border: 1px solid #ddd; padding: 10px; margin-bottom: 30px;">
                                        <div class="row">
                                            <div class="col-md-1">
                                                <ul class="list-unstyled profile-nav">
                                                    <li><img src="<?php echo $info['icon']['xs']?>" class="img-responsive" alt=""></li>
                                                </ul>
                                            </div>
                                            <div class="col-md-11">
                                                <div class="row">
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label class="col-md-4 control-label text-label">商品名称：</label>
                                                            <div class="col-md-8 text-val nickname"><?php echo $info['name'];?></div>
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label class="col-md-4 control-label text-label">副标题：</label>
                                                            <div class="col-md-8 text-val subtitle"><?php echo $info['subtitle'];?></div>
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label class="col-md-4 control-label text-label">商品价格：</label>
                                                            <div class="col-md-8 text-val"><?php echo $info['goods_price'];?></div>
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label class="col-md-4 control-label text-label">所属商家：</label>
                                                            <div class="col-md-8 text-val"><?php echo $merchant['shop_name'];?></div>
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label class="col-md-4 control-label text-label">打包费：</label>
                                                            <div class="col-md-8 text-val"><?php echo $info['lunch_box_fee'];?></div>
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label class="col-md-4 control-label text-label">所属分类：</label>
                                                            <div class="col-md-8 text-val"><?php echo isset($category['cat_name']) ? $category['cat_name'] : '';?></div>
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label class="col-md-4 control-label text-label">库存状态：</label>
                                                            <div class="col-md-8 text-val balance"><?php echo $info['is_limited'] == 1?'有限':'无限';?></div>
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label class="col-md-4 control-label text-label">库存量：</label>
                                                            <div class="col-md-8 text-val"><?php echo $info['quantity'];?></div>
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label class="col-md-4 control-label text-label">销售量：</label>
                                                            <div class="col-md-8 text-val"><?php echo $info['sale_quantity'];?></div>
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label class="col-md-4 control-label text-label">重量：</label>
                                                            <div class="col-md-8 text-val"><?php echo $info['weight'];?>g</div>
                                                        </div>
                                                    </div>
                                                    

                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label class="col-md-4 control-label text-label">状态：</label>
                                                            <div class="col-md-8 text-val"><?php echo $info['status']==1 ? '下架' : '上架';?></div>
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label class="col-md-4 control-label text-label">添加时间：</label>
                                                            <div class="col-md-8 text-val"><?php echo dateFormat($info['addtime']);?></div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!--end col-md-8-->
                    </div>
                    <!--end row-->
                    <div class="tabbable tabbable-custom tabbable-custom-profile">
                        <ul class="nav nav-tabs">
                            <li class="active"><a href="#tab_1_1" data-toggle="tab">查看评价</a></li>
                            <li class=""><a href="#tab_1_2" data-toggle="tab">规格组合</a></li>
                        </ul>
                        <div class="tab-content">
                            <!--查看评价-->
                            <div class="tab-pane active" id="tab_1_1">
                                <div class="table-actions-wrapper " style="float: right"></div>
                                <div class="table-responsive">
                                    <div class="table-container">
                                        <table class="table table-bordered table-hover" id="datatable">
                                            <thead>
                                                <tr role="row" class="heading">
                                                    <th> 评论内容</th>
                                                    <th width="150"> 评分</th>
                                                    <th width="100"> 评论人</th>
                                                    <th width="150"> 商家回复</th>
                                                    <th width="150"> 平台回复</th>
                                                    <th width="150"> 评论时间 </th>
                                                    <th width="155"> 操作 </th>
                                                </tr>
                                                <tr>
                                                    <th></th>
                                                    <th><input class="form-control form-filter input-sm" name="score" type="text"></th>
                                                    <th><input class="form-control form-filter input-sm" name="c_name" type="text"></th>
                                                    <th></th>
                                                    <th></th>
                                                    <th>
                                                        <div class="margin-bottom-5">
                                                            <input class="form-control form-filter input-sm" name="send_date_from" dp placeholder="从" type="text">
                                                        </div>
                                                        <input class="form-control form-filter input-sm" name="send_date_to" dp placeholder="到" type="text">
                                                    </th>
                                                    <th>
                                                        <div class="btn-group">
                                                            <a class="btn btn-xs filter-submit btn-default"><i class="fa fa-search"></i> 搜索</a>
                                                            <button data-toggle="dropdown" class="btn btn-default dropdown-toggle btn-xs" type="button"><i class="fa fa-angle-down"></i></button>
                                                            <ul role="menu" class="dropdown-menu pull-right">
                                                                <li><a href="javascript:void(0);" class="filter-cancel">重置</a></li>
                                                            </ul>
                                                        </div>
                                                    </th>
                                                </tr>
                                            </thead>
                                            <tbody></tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>

                            <!--商品规格-->
                            <div class="tab-pane" id="tab_1_2">
                                <div class="table-actions-wrapper " style="float: right"></div>
                                <div class="table-responsive">
                                    <div class="table-container">
                                        <!-- table -->
                                        <table class="table table-bordered table-hover" id="datatable_variant">
                                            <thead>
                                                <tr role="row" class="heading">
                                                    <th> 商品规格</th>
                                                    <th width="100"> 价格</th>
                                                    <th width="100"> 库存状态</th>
                                                    <th width="100"> 库存</th>
                                                    <th width="100"> 销量</th>
                                                    <th width="100"> 状态</th>
                                                    <th width="130"> 操作 </th>
                                                </tr>
                                            </thead>
                                            <tbody></tbody>
                                        </table>
                                        <!--  -->
                                    </div>
                                </div>
                            </div>

                            <!--标签价格-->
                            <div class="tab-pane" id="tab_1_3">
                                <div class="table-actions-wrapper " style="float: right">
                                </div>
                                <div class="table-responsive">
                                    <div class="table-container"></div>
                                </div>
                            </div>
                    </div>
                </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="save-modal" class="modal fade modal_small" role="dialog" aria-labelledby="myModalLabel1" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
        <h4 class="modal-title"></h4>
      </div>
      <form action="<?php echo getUrl('product/home/saveVariant'); ?>" class="form-horizontal" id="save-category-form" method="post">
        <div class="modal-body">
			<!--  -->
			<div class="form-group">
				<label class="control-label col-md-2">规格名称<span class="required">*</span></label>
				<div class="col-md-9">
					<input class="form-control required" id="name" disabled/>
				</div>
			</div>
			<!-- 价格 -->
			<div class="form-group">
				<label class="control-label col-md-2">价格<span class="required">*</span></label>
				<div class="col-md-9">
					<input class="form-control required number" name="price"/>
				</div>
			</div>
            <div class="form-group">
                <label class="control-label col-md-2">重量<span class="required">*</span></label>
                <div class="col-md-9">
                    <input class="form-control required number" name="weight"/>
                </div>
            </div>
			<div class="form-group">
				<label class="control-label col-md-2">库存状态<span class="required">*</span></label>
				<div class="col-md-9">
                    <div class="radio-list">
                        <label class="radio-inline" style="margin: 0 20px;"><input name="is_limited" value="1" type="radio"> 有限库存 </label>
                        <label class="radio-inline"><input name="is_limited" value="2" type="radio"> 无限库存 </label>
                    </div>
				</div>
			</div>
			<!-- 库存量 -->
			<div class="form-group">
				<label class="control-label col-md-2">库存量<span class="required">*</span></label>
				<div class="col-md-9">
					<input class="form-control number" name="quantity"/>
				</div>
			</div>
			<!--  -->
		</div>
        <div class="modal-footer">
          <input type="hidden" name="product_id" value=""/>
          <input type="hidden" name="sort" value=""/>
          <button class="btn default" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i> 关闭</button>
          <button type="submit" class="btn green field-submit-btn"><i class="fa fa-save"></i> 保存</button>
          <script type="text/javascript">
          	$(function(){
				var model = $('#save-modal');
				$('.add').live('click', function(){
					model.find('.modal-title').html('新增分类');
					model.find('.has-error').removeClass('has-error').find('.validate_message').remove();
					model.find('.show_message_error').remove();

// 					model.find('input[name="number"]').val('');
// 					model.find('input[name="online"]').val('');
					model.modal();
				});	
				
				$('.variant_edit').live('click', function(){
					model.find('.modal-title').html('编辑规格');
					model.find('.has-error').removeClass('has-error').find('.validate_message').remove();
					model.find('.show_message_error').remove();
					var url = $(this).attr('href');
					
					l_blockUI();
					$.get(url,{},function(data){
						data = eval('('+data+')');
//						console.log(data)
                        model.find('[type="radio"]').attr('checked', false);
                        model.find('[type="radio"][value="'+data.is_limited+'"]').attr('checked', true);
                        model.find('[type="radio"]').uniform();
						model.find('#name').val(data.property);
						model.find('input[name="price"]').val(data.price);
						model.find('input[name="weight"]').val(data.weight);
						model.find('input[name="quantity"]').val(data.quantity);
						model.find('input[name="product_id"]').val(data.product_id);
						model.find('input[name="sort"]').val(data.sort);
						 
						App.unblockUI();
						model.modal();
					});
					
					return false;
				});	
				
				
				$.e_validate.init('#save-category-form',{modal:model,ignore:'',successCallback:function(){
					$('#datatable_variant').dataTable().fnDraw(true);
				}});
            });
          </script>
        </div>
      </form>
    </div>
  </div>
</div>

<?php get_instance()->view('product/comment/img_form.php');?>
<?php get_instance()->view('product/comment/reply_form.php');?>

<script type="text/javascript">
	//异步删除
	function ajaxRequestCallBack(data){
		$('#datatable_variant').dataTable().fnDraw(true);
	}
    $(function(){
        datatable_init({
            "sDom": "<'row'<'col-md-5 col-sm-12'<'table-group-actions pull-right'>>r><'table-scrollable't><'row'<'col-md-8 col-sm-12'pli><'col-md-4 col-sm-12'>r>>",
            src: $("#datatable"),
            sAjaxSource: "<?php echo getUrl('product/home/getCommentList?product_id='.$info['id']);?>",
            aoColumnDefs : [{
                'bSortable' : false,
                'aTargets' : [ 0,2,3,4,6]
            }]
        });
        datatable_init({
            "sDom": "<'row'<'col-md-5 col-sm-12'<'table-group-actions pull-right'>>r><'table-scrollable't><'row'<'col-md-8 col-sm-12'pli><'col-md-4 col-sm-12'>r>>",
            src: $("#datatable_variant"),
            sAjaxSource: "<?php echo getUrl('product/home/getVariantList?product_id='.$info['id']);?>",
            aoColumnDefs : [{
                'bSortable' : false,
                'aTargets' : [ 0,4,5]
            }]
        });

        $('[dp]').not("[noinit]").datepicker({
            changeMonth: true,
            autoclose: true,
            format: "yyyy-mm-dd",
            language: 'zh-CN'
        });

        $('.content').live('mouseover',function(){
            $(this).height('75px');
        });

        $('.content').live('mouseout',function(){
            $(this).height('26px');
        });
    });
</script>
</body>
</html>